<? 
	include '../libraries/open_db_connection.php'; 
	include 'event_editor.php';
	
	$id=$_GET['id'];
	$action=$_GET['action'];
	
	switch ($action)
	{
		case make_active:
			make_active($id);
			$page=$_SERVER['HTTP_REFERER'];
		break;
		case make_inactive:
			make_inactive($id);
			$page=$_SERVER['HTTP_REFERER'];
		break;
		case edit:
			show_event_for_edit($id);
			include '../libraries/close_db_connection.php'; 
			die();
		break;
		case add_new:
			show_event_empty_form($id);
			include '../libraries/close_db_connection.php'; 
			die();
		break;
		case save:
			$id=$_POST['id'];
			$date=$_POST['date'];
			$summary=$_POST['summary'];
			$description=$_POST['description'];
			save_event($id,$date,$summary,$description);
			$page='index.php';
		break;
		case insert:
			$date=$_POST['date'];
			$summary=$_POST['summary'];
			$description=$_POST['description'];
			insert_event($date,$summary,$description);
			$page='index.php';
		break;
		case home_add:
			home_add($id);
			$page=$_SERVER['HTTP_REFERER'];
		break;
		case home_delete:
			home_delete($id);
			$page=$_SERVER['HTTP_REFERER'];
		break;
		default:
		die ("ERROR: no action taken");
		
		;
	}

 include '../libraries/close_db_connection.php'; 
 header("Refresh: 0;$page");
 ?>